home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Freeware
/
Read It Later 0.9924
/
read_it_later-0.9924-fx.xpi
/
chrome
/
isreaditlater.jar
/
content
/
ISRILgr.js
< prev
next >
Wrap
Text File
|
2008-10-28
|
6KB
|
123 lines
function ISRILgr()
{
this.empty = 'chrome://isreaditlater/skin/markempty16.png';
this.full = 'chrome://isreaditlater/skin/markfull16.png';
this.TO = null;
}
ISRILgr.prototype = {
_init : function() {
},
_initpage : function() {
if (content.document.getElementById('entries')) {
content.document.getElementById('entries').addEventListener('DOMNodeInserted', ISRILgr.readyUpdate, true);
}
ISRILxul.bi("appcontent").removeEventListener("DOMContentLoaded", this._initpage, false);
},
check : function() {
if (ISRILprefs.prefB('integrate-gr')) {
var u = ISRIL.url();
if (u.match('google') || u.match(/^https?:\/\/reader.google.(.+)/) || u.match(/^https?:\/\/([^.]+\.)?google.(.+)\/reader/)) {
ISRILxul.bi("appcontent").addEventListener("DOMContentLoaded", this._initpage, true);
}
}
},
readyUpdate : function() {
clearInterval(ISRILgr.TO);
ISRILgr.TO = setTimeout('ISRILgr.updateEntries()', 50);
},
updateEntries : function() {
var entries = this.getElementsByClassName(content.document, 'entry', null, 'ril-set');
if (entries.length > 0) {
ISRIL.GetList();
for(var i = 0; i<entries.length; i++) {
if (!entries[i].className.match('ril-set')) {
//Create Checkmark
checkmark = content.document.createElement('img');
//Determine View Type
org = this.getElementsByClassName(entries[i], 'entry-original')[0];
titleLink = this.getElementsByClassName(entries[i], 'entry-title-link')[0];
if (org || titleLink) {
if (org) {
viewType = 'list';
url = org.href;
pageTitle = this.getElementsByClassName(entries[i], 'entry-title')[0].innerHTML;
sec = this.getElementsByClassName(entries[i], 'entry-secondary')[0];
source = this.getElementsByClassName(entries[i], 'entry-source-title')[0];
ctn = content.document.getElementById('entries').className.match('single-source') ? sec : source;
checkmark.style.marginRight = '9px';
} else if (titleLink) {
viewType = 'expanded';
url = titleLink.href;
pageTitle = titleLink.innerHTML.replace(/<([^>]+)>/, '').replace(/(^\s+|\s+$)/, '') + '';
ctn = this.getElementsByClassName(entries[i], 'entry-icons')[0];
}
//Set Checkmark attributes
checkmark.src = ISRILglobals.ResolverIndex[url] ? this.full : this.empty;
checkmark.width = 15;
checkmark.height = 15;
checkmark.style.cursor = 'pointer';
//Get Info and Nodes
checkmark.setAttribute('url', url);
checkmark.setAttribute('pageTitle', pageTitle);
checkmark.addEventListener("click", this.clickMark, true);
//Add Checkmark
ctn.insertBefore( checkmark , ctn.firstChild );
}
entries[i].className += ' ril-set';
}
}
}
},
clickMark : function(e) {
e.stopPropagation();
if (this.src == ISRILgr.full) {
ISRIL.MarkAsRead( ISRILglobals.ResolverIndex[ this.getAttribute('url') ].itemId, true );
this.src = ISRILgr.empty;
} else {
ISRIL.SaveLink( this.getAttribute('url') , this.getAttribute('pageTitle') );
this.src = ISRILgr.full;
}
},
// -- //
getElementsByClassName : function (parent, className, nodeName, notClassName) {
var result = [], tag = nodeName||'*', node, seek, i;
var rightClass = new RegExp( '(^| )'+ className +'( |$)' );
var wrongClass = new RegExp( '(^| )'+ notClassName +'( |$)' );
seek = parent.getElementsByTagName( tag );
for( i=0; i<seek.length; i++ )
if( rightClass.test( (node = seek[i]).className ) && !wrongClass.test( (node = seek[i]).className ) )
result.push( seek[i] );
return result;
},
}
ISRILgr = new ISRILgr();